package com.bwie.controller;

import com.bwie.Goods;
import com.bwie.service.GoodsService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     * 添加方法
     */
    @RequestMapping("/add")
    public  void add(@RequestBody Goods goods){
        int i = goodsService.add(goods);
        if(i>0){
            int i12 = 100;
            i12+=1;
            //添加到redis中
            System.out.println("你丹佛市分公司可几点给你接口啥的放歌了");
            System.out.println("浮点数刚发的郜怀达好嘛");
            System.out.println("发啊啊烦都烦死");
            redisTemplate.opsForValue().set("good",goods);
            //发送mq
            rabbitTemplate.convertAndSend("1908a",goods);
        }
    }
}
